package com.example.lagoues;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;

public class Utils {
    
    private static ObjectMapper objectMapper = new ObjectMapper();
    static {
        objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    }
    
    public static <T> T toBean(String json, Class<T> beanClz) {
        try {
            return objectMapper.readValue(json, beanClz);
        } catch (JsonProcessingException e) {
            throw new RuntimeException(e);
        }
    }
    
}
